package com.prizedraw.prize_draw.excel;


import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.prizedraw.prize_draw.common.sheet.UserUpLoad;

import java.util.ArrayList;
import java.util.List;


public class ExcelListener extends AnalysisEventListener<UserUpLoad> {

    private List<UserUpLoad> data = new ArrayList<>();

    /*private static final int BATCH_COUNT = 3000;
    private UserDao userDao;

    public ExcelListener(UserDao userDao){
        this.userDao = userDao;
    }*/

    @Override
    public void invoke(UserUpLoad userUpLoad, AnalysisContext analysisContext) {
        // 每读取一条记录，都会到这里来
        data.add(userUpLoad);

        // 得对读取的内容进行判断，先让其全部读取，后面再分情况
        /*if(datas.size() >= BATCH_COUNT){
            saveData();
            // 存储完成清理datas
            datas.clear();
        }*/
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

    public List<UserUpLoad> getData() {
        return data;
    }

    public void setData(List<UserUpLoad> data) {
        this.data = data;
    }
}
